package com.zsw.controller;

import com.zsw.service.StorageService;
import com.zsw.vo.StorageVO;
import feign.FeignException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zhangsw
 */
@RestController
@Api("商品服务")
public class StorageController {

    @Resource
    private StorageService storageService;

    @ApiOperation("扣除商品库存")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commodityCode",value = "商品代号"),
            @ApiImplicitParam(name = "count",value = "商品数量")
    })
    @PostMapping(value = "/storage/deduct")
    public boolean deductStorage(@RequestBody StorageVO storageVO)throws FeignException {
        return storageService.deduct(storageVO.getCommodityCode(),storageVO.getCount()) ;
    }
}
